/***************************************************************************
 *   Copyright (C) 2007 by Ivan Vasić                    *
 *   ivasic@gmail.com                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef ANNOUNCEREQUEST_H
#define ANNOUNCEREQUEST_H

#include "request.h"

#include <QString>
#include <QByteArray>
#include <QHttpRequestHeader>
#include <QHostAddress>
#include <QUrl>
		
enum AnnounceEvent
{
	EVENT_NOT_SET,
	EVENT_STARTED,
	EVENT_STOPPED,
	EVENT_COMPLETED,
	EVENT_EMPTY
};

class QTcpSocket;
class SHA1Hash;

/**
 * @author Ivan Vasić <ivasic@gmail.com>
 *
 * @b Primer: <br><br>
 * announce?peer_id=-KT21DV-940704469736&port=50000&uploaded=0&downloaded=0&left=611&compact=1&numwant=100&key=1708995939&event=started&info_hash=Yy%914%c5)%0b%d9%18%19%f3W%835%22%20vx%f6%16 HTTP/1.1

*/

class AnnounceRequest : public Request
{
	public:
		AnnounceRequest(const QHttpRequestHeader& request, QTcpSocket* socket);
		~AnnounceRequest();

		bool isValid() const;
		
		static QString announceEventToString(AnnounceEvent event);

		/* ACCESSORS */

		QByteArray peerID() const;
		quint16 port() const;
		quint64 downloaded() const;
		quint64 uploaded() const;
		quint64 left() const;
		bool compact() const;
		int numwant() const;
		QString key() const;
		AnnounceEvent event() const;
		SHA1Hash infohash() const;
		QTcpSocket* socket() const;
		const QString& userAgent() const;
		QHostAddress ip() const;
		QByteArray passkey() const;		

	protected:
		QUrl m_url;
		QTcpSocket* m_socket;
		QString m_userAgent;
		QString m_passkey;
};

#endif
